package com.lujianfei.share;


import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ProviderInfo;
import android.util.Log;

public class ShareContext {

    private static final String TAG = "ShareContext";

    public static String authorities = "com.lujianfei.waterpower.fileprovider";

    public static void init(Context context){
        getPackageInfo(context,context.getPackageName());
    }
    private static void getPackageInfo(Context context, String packageName) {
        try {
            PackageInfo info = context.getPackageManager().getPackageInfo(packageName,
                    PackageManager.GET_PROVIDERS);
            ProviderInfo[] providers = info.providers;
            for (ProviderInfo provider : providers) {
                Log.d(TAG, "name is " + provider.name);
                Log.d(TAG, "authority is " + provider.authority);
                authorities = provider.authority;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
